<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="${cfg.package_name}.mapper.${entity}Mapper">

    <resultMap id="BaseResultMap" type="${cfg.package_name}.bean.${entity}" >
    <#list table.fields as field>
    <#if field.keyFlag>
        <id column="${field.name}" property="${field.propertyName}"/>
    </#if>
    <#if !field.keyFlag>
        <result column="${field.name}" property="${field.propertyName}" />
    </#if>
    </#list>
    </resultMap>

    <sql id="Base_Column_List" >
    <#list table.fields as field>
        ${field.name}${field_has_next?string(",","")}
    </#list>
    </sql>

    <select id="myPage" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from ${table.name} t1 ${r"$"}{ew.customSqlSegment}
    </select>

    <select id="mySelectSum" resultMap="BaseResultMap">
        select count(1) as id
         from ${table.name} t1 ${r"$"}{ew.customSqlSegment}
    </select>

    <select id="mySelectListCount" resultType="java.lang.Integer">
        select count(t1.delete_flag)
        from ${table.name} t1 ${r"$"}{ew.customSqlSegment}
    </select>

    <select id="mySelectBy" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from ${table.name} t1 ${r"$"}{ew.customSqlSegment}
    </select>

    <select id="mySelectById" resultMap="BaseResultMap" >
        select
        <include refid="Base_Column_List" />
        from ${table.name} t1 where id = ${r"#"}{id,jdbcType=BIGINT}
    </select>

</mapper>
